import request from "@/utils/request";

const BASE_URL = "/admin-api/role";

class RoleAPI {
  static getMenu() {
    return request<any, any>({
      url: `${BASE_URL}/listMenu`,
      method: "get",
    });
  }

  static getRoleList(queryParams: any) {
    return request<any, any>({
      url: `${BASE_URL}/list`,
      method: "get",
      params: queryParams,
    });
  }

  static updateRole(data: any) {
    return request<any, any>({
      url: `${BASE_URL}/updateRole`,
      method: "post",
      data,
    });
  }

  static deleteRole(id: number) {
    return request<any, any>({
      url: `${BASE_URL}/deleteRole/${id}`,
      method: "delete",
    });
  }

  static getRoleMenuList(roleId: number) {
    return request<any, any>({
      url: `${BASE_URL}/listMenu/${roleId}`,
      method: "get",
    });
  }

  static allocMenu(data: any) {
    return request<any, any>({
      url: `${BASE_URL}/allocMenu`,
      method: "post",
      data,
    });
  }

  static createRole(data: any) {
    return request<any, any>({
      url: `${BASE_URL}/create`,
      method: "post",
      data,
    });
  }
}

export default RoleAPI;
